import { PURCHASEWAY_TEXT } from '@/constant/purchase'
import { TableColumnsType, Tooltip, Typography } from 'antd'
import dayjs from 'dayjs'
import { NavigateFunction } from 'react-router-dom'
import type { DashBoardTimeAchieveVO } from './types'
export const useOneBigClassColumns = ({
  setdefaultKey,
  navigate,
}: {
  setdefaultKey: React.Dispatch<React.SetStateAction<string>>
  navigate: NavigateFunction
}): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '大类',
    dataIndex: 'dimension',
    key: 'dimension',
    align: 'center',
    fixed: 'left',
    width: 100,
    sorter: true,
    defaultSortOrder: 'ascend',
    render: (info) => (
      <Typography.Link
        onClick={() => {
          setdefaultKey('spu')
          navigate('/monitor/fulllink/list?type=spu&dimension=' + info)
        }}
      >
        {info || '-'}
      </Typography.Link>
    ),
  },
  {
    title: '总周期（坑位规划 -> 到仓）',
    dataIndex: 'totalCycle',
    key: 'totalCycle',
    sorter: true,
    align: 'center',
    width: 130,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '坑位规划 -> 商品选中',
    dataIndex: 'planToSelect',
    key: 'planToSelect',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '坑位规划 -> 意向订单',
    dataIndex: 'planToIntention',
    key: 'planToIntention',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '意向订单 -> 正式订单',
    dataIndex: 'intentionToOrder',
    key: 'intentionToOrder',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '正式订单 -> 到仓',
    dataIndex: 'orderToWarehouse',
    key: 'orderToWarehouse',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
]

export const useTwoBigClassColumns = ({
  setdefaultKey,
  navigate,
}: {
  setdefaultKey: React.Dispatch<React.SetStateAction<string>>
  navigate: NavigateFunction
}): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '大类',
    dataIndex: 'dimension',
    key: 'dimension',
    align: 'center',
    fixed: 'left',
    width: 100,
    sorter: true,
    defaultSortOrder: 'descend',
    render: (info) => (
      <Typography.Link
        onClick={() => {
          setdefaultKey('spu')
          navigate('/monitor/fulllink/list?type=spu&dimension=' + info)
        }}
      >
        {info || '-'}
      </Typography.Link>
    ),
  },
  {
    title: '总周期（需求提报 -> 到仓）',
    dataIndex: 'totalCycle',
    key: 'totalCycle',
    align: 'center',
    width: 130,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '需求提报 -> 商品选中',
    dataIndex: 'demandToSelected',
    key: 'demandToSelected',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '需求提报 -> 意向订单',
    dataIndex: 'demandToIntention',
    key: 'demandToIntention',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '意向订单 -> 正式订单',
    dataIndex: 'intentionToOrder',
    key: 'intentionToOrder',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '正式订单 -> 到仓',
    dataIndex: 'orderToWarehouse',
    key: 'orderToWarehouse',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
]

export const useThreeBigClassColumns = ({
  setdefaultKey,
  navigate,
}: {
  setdefaultKey: React.Dispatch<React.SetStateAction<string>>
  navigate: NavigateFunction
}): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '大类',
    dataIndex: 'dimension',
    key: 'dimension',
    align: 'center',
    fixed: 'left',
    width: 100,
    sorter: true,
    defaultSortOrder: 'descend',
    render: (info) => (
      <Typography.Link
        onClick={() => {
          setdefaultKey('spu')
          navigate('/monitor/fulllink/list?type=spu&dimension=' + info)
        }}
      >
        {info || '-'}
      </Typography.Link>
    ),
  },
  {
    title: '总周期（首销 -> 返单到仓）',
    dataIndex: 'totalCycle',
    key: 'totalCycle',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '首销 -> 意向订单',
    dataIndex: 'firstSaleToIntention',
    key: 'firstSaleToIntention',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '意向订单 -> 正式订单',
    dataIndex: 'intentionToOrder',
    key: 'intentionToOrder',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
  {
    title: '正式订单 -> 到仓',
    dataIndex: 'orderToWarehouse',
    key: 'orderToWarehouse',
    align: 'center',
    width: 100,
    render: (info) => (info == 0 ? '-' : info),
  },
]

export const useOneSpuColumns = (): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '维度',
    align: 'center',
    children: [
      {
        title: '款式编码',
        dataIndex: 'dimension',
        key: 'dimension',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
      {
        title: '款式名称',
        dataIndex: 'spuName',
        key: 'spuName',
        align: 'center',
        fixed: 'left',
        width: 160,
        ellipsis: {
          showTitle: false,
        },
        render: (info) => {
          return info ? (
            <Tooltip placement="top" title={info}>
              <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>{info}</div>
            </Tooltip>
          ) : (
            '-'
          )
        },
      },
      {
        title: '采购方式',
        dataIndex: 'purchaseType',
        key: 'purchaseType',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => {
          return PURCHASEWAY_TEXT[info] || '-'
        },
      },
      {
        title: '季节分组',
        dataIndex: 'seasonGroup',
        key: 'seasonGroup',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
    ],
  },
  {
    title: '周期',
    align: 'center',
    className: 'fulllink_table_header_02',
    children: [
      {
        title: '总周期（坑位规划 -> 到仓）',
        dataIndex: 'totalCycle',
        key: 'totalCycle',
        align: 'center',
        width: 180,
        sorter: true,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '坑位规划 -> 商品选中',
        dataIndex: 'planToSelect',
        key: 'planToSelect',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '坑位规划 -> 意向订单',
        dataIndex: 'planToIntention',
        key: 'planToIntention',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '意向订单 -> 正式订单',
        dataIndex: 'intentionToOrder',
        key: 'intentionToOrder',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '正式订单 -> 到仓',
        dataIndex: 'orderToWarehouse',
        key: 'orderToWarehouse',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
    ],
  },
  {
    title: '时间明细',
    align: 'center',
    className: 'fulllink_table_header_01',
    children: [
      {
        title: '坑位创建时间',
        dataIndex: 'planTime',
        key: 'planTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '款式创建时间',
        dataIndex: 'spuTime',
        key: 'spuTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '意向选中时间',
        dataIndex: 'intentSelectTime',
        key: 'intentSelectTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '核价完成时间',
        dataIndex: 'checkPriceTime',
        key: 'checkPriceTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '商品选中时间',
        dataIndex: 'spuSelectTime',
        key: 'spuSelectTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '意向订单时间',
        dataIndex: 'intentOrderTime',
        key: 'intentOrderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '回复意向订单时间',
        dataIndex: 'intentOrderReplyTime',
        key: 'intentOrderReplyTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '正式订单时间',
        dataIndex: 'orderTime',
        key: 'orderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '到仓时间',
        dataIndex: 'warehouseTime',
        key: 'warehouseTime',
        align: 'center',
        width: 180,
        sorter: true,
        defaultSortOrder: 'descend',
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '计划上市时间',
        dataIndex: 'planReleaseTime',
        key: 'planReleaseTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '要求到货时间',
        dataIndex: 'requireTime',
        key: 'requireTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
    ],
  },
]

export const useTwoSpuColumns = (): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '维度',
    align: 'center',
    children: [
      {
        title: '款式编码',
        dataIndex: 'dimension',
        key: 'dimension',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
      {
        title: '款式名称',
        dataIndex: 'spuName',
        key: 'spuName',
        align: 'center',
        fixed: 'left',
        width: 160,
        ellipsis: {
          showTitle: false,
        },
        render: (info) => {
          return info ? (
            <Tooltip placement="top" title={info}>
              <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>{info}</div>
            </Tooltip>
          ) : (
            '-'
          )
        },
      },
      {
        title: '采购方式',
        dataIndex: 'purchaseType',
        key: 'purchaseType',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => {
          return PURCHASEWAY_TEXT[info] || '-'
        },
      },
      {
        title: '季节分组',
        dataIndex: 'seasonGroup',
        key: 'seasonGroup',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
    ],
  },
  {
    title: '周期',
    align: 'center',
    className: 'fulllink_table_header_02',
    children: [
      {
        title: '总周期（需求提报 -> 到仓）',
        dataIndex: 'totalCycle',
        key: 'totalCycle',
        align: 'center',
        width: 180,
        sorter: true,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '需求提报 -> 商品选中',
        dataIndex: 'demandToSelected',
        key: 'demandToSelected',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '需求提报 -> 意向订单',
        dataIndex: 'demandToIntention',
        key: 'demandToIntention',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '意向订单 -> 正式订单',
        dataIndex: 'intentionToOrder',
        key: 'intentionToOrder',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '正式订单 -> 到仓',
        dataIndex: 'orderToWarehouse',
        key: 'orderToWarehouse',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
    ],
  },
  {
    title: '时间明细',
    align: 'center',
    className: 'fulllink_table_header_01',
    children: [
      {
        title: '需求提报时间',
        dataIndex: 'demandTime',
        key: 'demandTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '核价完成时间',
        dataIndex: 'checkPriceTime',
        key: 'checkPriceTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '正式商品时间',
        dataIndex: 'spuTime',
        key: 'spuTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '意向订单时间',
        dataIndex: 'intentOrderTime',
        key: 'intentOrderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '回复意向订单时间',
        dataIndex: 'intentOrderReplyTime',
        key: 'intentOrderReplyTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '正式订单时间',
        dataIndex: 'orderTime',
        key: 'orderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '到仓时间',
        dataIndex: 'warehouseTime',
        key: 'warehouseTime',
        align: 'center',
        width: 180,
        sorter: true,
        defaultSortOrder: 'descend',
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '计划上市时间',
        dataIndex: 'planReleaseTime',
        key: 'planReleaseTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '要求到货时间',
        dataIndex: 'requireTime',
        key: 'requireTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
    ],
  },
]

export const useThreeSpuColumns = (): TableColumnsType<DashBoardTimeAchieveVO> => [
  {
    title: '维度',
    align: 'center',
    children: [
      {
        title: '款式编码',
        dataIndex: 'dimension',
        key: 'dimension',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
      {
        title: '款式名称',
        dataIndex: 'spuName',
        key: 'spuName',
        align: 'center',
        fixed: 'left',
        width: 160,
        ellipsis: {
          showTitle: false,
        },
        render: (info) => {
          return info ? (
            <Tooltip placement="top" title={info}>
              <div style={{ overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>{info}</div>
            </Tooltip>
          ) : (
            '-'
          )
        },
      },
      {
        title: '采购方式',
        dataIndex: 'purchaseType',
        key: 'purchaseType',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => {
          return PURCHASEWAY_TEXT[info] || '-'
        },
      },
      {
        title: '季节分组',
        dataIndex: 'seasonGroup',
        key: 'seasonGroup',
        align: 'center',
        fixed: 'left',
        width: 100,
        render: (info) => info || '-',
      },
    ],
  },
  {
    title: '周期',
    align: 'center',
    className: 'fulllink_table_header_02',
    children: [
      {
        title: '总周期（首销 -> 返单到仓）',
        dataIndex: 'totalCycle',
        key: 'totalCycle',
        align: 'center',
        width: 180,
        sorter: true,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '首销 -> 意向订单',
        dataIndex: 'firstSaleToIntention',
        key: 'firstSaleToIntention',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '意向订单 -> 正式订单',
        dataIndex: 'intentionToOrder',
        key: 'intentionToOrder',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
      {
        title: '正式订单 -> 到仓',
        dataIndex: 'orderToWarehouse',
        key: 'orderToWarehouse',
        align: 'center',
        width: 180,
        render: (info) => (info == null ? '数据缺失' : info),
      },
    ],
  },
  {
    title: '时间明细',
    align: 'center',
    className: 'fulllink_table_header_01',
    children: [
      {
        title: '首销时间',
        dataIndex: 'firstSaleTime',
        key: 'firstSaleTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '意向订单时间',
        dataIndex: 'intentOrderTime',
        key: 'intentOrderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '回复意向订单时间',
        dataIndex: 'intentOrderReplyTime',
        key: 'intentOrderReplyTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '正式订单时间',
        dataIndex: 'orderTime',
        key: 'orderTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '到仓时间',
        dataIndex: 'warehouseTime',
        key: 'warehouseTime',
        align: 'center',
        width: 180,
        sorter: true,
        defaultSortOrder: 'descend',
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
      {
        title: '要求到货时间',
        dataIndex: 'requireTime',
        key: 'requireTime',
        align: 'center',
        width: 180,
        render: (info) => (info ? dayjs(info).format('YYYY-MM-DD') : '-'),
      },
    ],
  },
]
